package test00.lx09.demo02;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @author CSY
 * @date 2025 - 04 - 08
 */
@SuppressWarnings({"all"})
public class MainTest {
    public static void main(String[] args) {
        Class<UserService> clazz = UserService.class;
        Method[] methods = clazz.getMethods();
        Stream<Method> stream = Arrays.stream(methods);
        stream.filter((t) ->  t.isAnnotationPresent(ExceptionHandler.class))
                .sorted((o1,o2) ->
                        o1.getAnnotation(ExceptionHandler.class)
                                .value()
                                .isAssignableFrom(o2.getAnnotation(ExceptionHandler.class).value()) ? 1 : -1)
                .map(Method::getName)
                .forEach(System.out::println);
    }
}
